package com.hmdp.controller;


import com.hmdp.dto.Result;
import com.hmdp.service.IFollowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 虎哥
 * @since 2021-12-22
 */
@RestController
@RequestMapping("/follow")
public class FollowController {
    @Autowired
    private IFollowService followService;

    /**
     * 关注/取关
     * @param followUsereId 当前用户id
     * @param isFollow true关注/false取关
     * @return boolean
     */
    @PutMapping("/{id}/{isFollow}")
    public Result follow(@PathVariable("id") Long followUsereId,@PathVariable("isFollow")Boolean isFollow){
        return followService.follow(followUsereId,isFollow);
    }

    /**
     * 是否关注该id的用户？
     * @param followUsereId
     * @return
     */
    @GetMapping("or/not/{id}")
    public Result isFollow(@PathVariable("id") Long followUsereId){
        return followService.isfollow(followUsereId);
    }

    /**
     * 查看当前用户与该id用户的共同关注
     * @param id
     * @return
     */
    @GetMapping("/common/{id}")
    public Result followCommons(@PathVariable("id") Long id) {
        return followService.followCommons(id);
    }
}
